package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketComment;
import com.cskaoyan.market.db.mapper.MarketCommentMapper;
import com.cskaoyan.market.db.mapper.MarketGoodsMapper;
import com.cskaoyan.market.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.time.LocalDateTime;

public class AdminOrderReplyServiceImpl implements AdminOrderReplyService{
    @Override
    public boolean reply(String commentId, String content) {
        SqlSession session= MybatisUtils.getSession();
        MarketCommentMapper mapper = session.getMapper(MarketCommentMapper.class);
        MarketComment marketComment = mapper.selectByPrimaryKey(Integer.valueOf(commentId));
        System.out.println("marketComment = " + marketComment);
        Integer valueId = marketComment.getValueId();

        MarketComment marketComment1 = new MarketComment();
        marketComment1.setContent(content);
        marketComment1.setValueId(valueId);
        marketComment1.setType((byte) 1);
        marketComment1.setUserId(marketComment.getUserId());
        marketComment1.setUpdateTime(LocalDateTime.now());
        marketComment1.setAddTime(LocalDateTime.now());
        int insert = mapper.insert(marketComment1);
        session.commit();
        session.close();
        if (insert!=0){
            return true;
        }
        return false;
    }
}
